/**
 * Copyright (C), 2015-2019, bogewang
 * FileName: VerifyController
 * Author:   foren236598164@aliyun.com
 * Date:     2019/9/19 10:55
 * Description: 验证码控制类
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.bogewang.code;

import com.bogewang.web.utils.RandomValidateCodeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 〈验证码控制类〉
 *
 * @author foren236598164@aliyun.com
 * @create 2019/9/19
 * @since 1.0.0
 */
@Controller
public class VerifyController {

    /**
     * 生成验证码;
     * @param request
     * @param response
     */
    @RequestMapping("/getVerify")
    public void getVerify(HttpServletRequest request, HttpServletResponse response){
        try {
            response.setContentType("image/jpeg");
            response.setHeader("Pragma", "No-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expire", 0);
            RandomValidateCodeUtil randomValidateCode = new RandomValidateCodeUtil();
            randomValidateCode.getRandcode(request, response);// 输出验证码图片方法
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}